			
			
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript"
	src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBXjLdTmaYkzOIa-uIHnlWCCEm2MCCiMPg&sensor=true">
</script>
<script>
$(document).ready(function(){
		drawGmaps("0");
		<?php 
		//	foreach ($kota->result_array() as $row){
			//	echo "
				//		drawChartDist('".$row['ID_KOTA']."');
					//	drawChartStock('".$row['ID_KOTA']."');
					//";
				//break;
			//}
		?>
		
	});
</script>
<script>
	var peternakanIconBase = '<?= base_url().'img/misc/'; ?>';
	function initialize(jenisTP){
		var mapProp = {
			center: new google.maps.LatLng(-7.28755, 112.733),
			zoom: 8,
			mapTypeId: google.maps.MapTypeId.ROADMAP
		};
		var map = new google.maps.Map(document.getElementById("ch-TP"), mapProp);
		allMaps.push(map);			
		<?php
			//var_dump($peternakan->result_array());
			if($titik_pasok != null){
				foreach($titik_pasok as $titik){
					$icon;
					if($titik["JENIS"] == "1"){
						$icon = "peternakan.png";
					}
					if($titik["JENIS"] == "2"){
						$icon = "rph.png";
					}
					if($titik["JENIS"] == "3"){
						$icon = "titik_penjualan.png";
					}
					if($titik["JENIS"] == "4"){
						$icon = "agen_sapi.png";
					}
					echo "
						if(jenisTP!=0){
							if(".$titik["JENIS"]."==jenisTP){
								var marker".$titik['ID_TITIK']." = new google.maps.Marker();
								marker".$titik['ID_TITIK'].".setPosition(new google.maps.LatLng(".$titik['LAT'].", ".$titik['LON']."));
								marker".$titik['ID_TITIK'].".setMap(map);
								
								marker".$titik['ID_TITIK'].".setIcon(peternakanIconBase + '".$icon."');
									
								var content".$titik['ID_TITIK']." = 'Nama: ".$titik['NAMA']." <br>Alamat: ".$titik['ALAMAT']."';
								var infoWindow".$titik['ID_TITIK']." = new google.maps.InfoWindow({content: content".$titik['ID_TITIK']."});
									
								onSpotClicked(marker".$titik['ID_TITIK'].", content".$titik['ID_TITIK'].", infoWindow".$titik['ID_TITIK'].", map);
									
								allMarkers[".$titik['ID_TITIK']."] = marker".$titik['ID_TITIK'].";
							}
						} else {
							var marker".$titik['ID_TITIK']." = new google.maps.Marker();
							marker".$titik['ID_TITIK'].".setPosition(new google.maps.LatLng(".$titik['LAT'].", ".$titik['LON']."));
							marker".$titik['ID_TITIK'].".setMap(map);
							
							marker".$titik['ID_TITIK'].".setIcon(peternakanIconBase + '".$icon."');
								
							var content".$titik['ID_TITIK']." = 'Nama: ".$titik['NAMA']." <br>Alamat: ".$titik['ALAMAT']."';
							var infoWindow".$titik['ID_TITIK']." = new google.maps.InfoWindow({content: content".$titik['ID_TITIK']."});
								
							onSpotClicked(marker".$titik['ID_TITIK'].", content".$titik['ID_TITIK'].", infoWindow".$titik['ID_TITIK'].", map);
								
							allMarkers[".$titik['ID_TITIK']."] = marker".$titik['ID_TITIK'].";
						}
					";
					
				}
			}		
		?>				
	}
	function onSpotClicked(marker, content, infowindow, map){
		google.maps.event.addListener(marker, "mouseover", function () {
			infowindow.setContent(content);
			infowindow.open(map,this);
		});		
		google.maps.event.addListener(marker, "mouseout", function () {
			infowindow.close();
		});
	}
	var allMarkers = [];

				
	function placeMarker(position, map) {
		var marker = new google.maps.Marker({
			position: position,
			map: map
		});
		map.panTo(position);
		marker.setIcon(peternakanIconBase + 'peternakan.png');
		markers.push(marker);
		map.setCenter(marker.getPosition());
	}
	
	var markers = [];
	var allMaps = [];
	function drawGmaps(jenisTP){
		google.maps.event.addDomListener(window, 'load', initialize(jenisTP));
	}
	
</script>
			
			<script type="text/javascript">
			  google.load("visualization", "1", {packages:["corechart"]});
			  google.setOnLoadCallback(drawChart);
			  google.setOnLoadCallback(drawChart2);
			  google.setOnLoadCallback(drawChart3);
			  function drawChart() {
				var data = google.visualization.arrayToDataTable([
				  ['Task', 'Pulau'],
				  ['Sumatera Utara', 4034],
				 ['Sumatera Barat', 2388],
				 ['Riau', 3433],
				 ['Jambi', 343],
				 ['Bengkulu', 900],
				 ['Lampung', 9384],
				 ['Kepulauan Bangka', 9878],
				 ['Kepulauan Riau', 8374],
				 ['Jakarta', 34010],
				 ['Jawa Barat', 23989],
				 ['Jawa Tengah', 9333],
				 ['Yogyakarta', 3343],
				 ['Jawa Timur', 9007],
				 ['Banten', 3843],
				 ['Bali', 9800],
				 ['Nusa Tenggara barat', 3333],
				 ['Nusa Tenggara Timur', 3333],
				 ['Kalimantan Barat', 3344],
				 ['Kalimantan Tengah', 3222],
				 ['Kalimantan Selatan', 9002],
				 ['Kalimantan Timur', 2444],
				 ['Sulawesi Utara', 5334],
				 ['Sulawesi Tengah',300],
				 ['Sulawesi Selatan', 2200],
				 ['Sulawesi Tenggara', 400],
				 ['Gorontalo', 1020],
				 ['Sulawesi Barat', 900],
				 ['Maluku', 2900]
				  
				]);
	 

				var options = {
				  title: 'Jumlah sapi tiap provinsi'
				};

				var chart = new google.visualization.PieChart(document.getElementById('piechart'));
				chart.draw(data, options);
			  }
			  
			  function drawChart2() {
				var data = google.visualization.arrayToDataTable([
				  ['Task', 'Pulau'],
				  ['Sumatera Utara', 4390],
				 ['Sumatera Barat', 4333],
				 ['Riau', 4333],
				 ['Jambi', 9000],
				 ['Bengkulu', 9322],
				 ['Lampung', 8909],
				 ['Kepulauan Bangka', 1000],
				 ['Kepulauan Riau', 1000],
				 ['Jakarta', 8900],
				 ['Jawa Barat', 4390],
				 ['Jawa Tengah', 799],
				 ['Yogyakarta', 34333],
				 ['Jawa Timur', 9000],
				 ['Banten', 5400],
				 ['Bali', 5490],
				 ['Nusa Tenggara barat', 4000],
				 ['Nusa Tenggara Timur', 488],
				 ['Kalimantan Barat', 4330],
				 ['Kalimantan Tengah', 9000],
				 ['Kalimantan Selatan', 10000],
				 ['Kalimantan Timur', 9000],
				 ['Sulawesi Utara', 4300],
				 ['Sulawesi Tengah',4300],
				 ['Sulawesi Selatan', 1000],
				 ['Sulawesi Tenggara', 2090],
				 ['Gorontalo', 1020],
				 ['Sulawesi Barat', 1032],
				 ['Maluku', 5000]
				  
				]);
	 

				var options = {
				  title: 'Jumlah daging sapi tiap provinsi'
				};

				var chart = new google.visualization.PieChart(document.getElementById('piechart2'));
				chart.draw(data, options);
			  }
			  
			  function drawChart3() {
				var data = google.visualization.arrayToDataTable([
				  ['Provinsi', 'Permintaan', 'Persediaan'],
				  ['Sumatera Utara', 4390, 5049],
				 ['Sumatera Barat', 4333, 7000],
				 ['Riau', 4333, 8000],
				 ['Jambi', 9000, 322],
				 ['Bengkulu', 9322, 12034],
				 ['Lampung', 8909, 4000],
				 ['Kepulauan Bangka', 1000, 4300],
				 ['Kepulauan Riau', 1000, 500],
				 ['Jakarta', 8900, 4389],
				 ['Jawa Barat', 4390, 9000],
				 ['Jawa Tengah', 799, 1208],
				 ['Yogyakarta', 3433, 4332],
				 ['Jawa Timur', 9000, 4389],
				 ['Banten', 5400, 5400],
				 ['Bali', 5490, 5788],
				 ['Nusa Tenggara barat', 4000, 7482],
				 ['Nusa Tenggara Timur', 488, 679],
				 ['Kalimantan Barat', 4330, 4389],
				 ['Kalimantan Tengah', 9000, 4389],
				 ['Kalimantan Selatan', 10000, 13838],
				 ['Kalimantan Timur', 9000, 7600],
				 ['Sulawesi Utara', 4300, 4311],
				 ['Sulawesi Tengah',4300, 2000],
				 ['Sulawesi Selatan', 1000, 2311],
				 ['Sulawesi Tenggara', 2090, 1389],
				 ['Gorontalo', 1020, 3211],
				 ['Sulawesi Barat', 1032, 4329],
				 ['Maluku', 5000, 3289]
				]);

				var options = {
				  title: 'Jumlah Permintaan dan Persediaan tiap provinsi',
				  vAxis: {title: 'Provinsi',  titleTextStyle: {color: 'red'}}
				};

				var chart = new google.visualization.BarChart(document.getElementById('chart_div'));
				chart.draw(data, options);
			  }
			</script>
			
			<script type="text/javascript"
			  src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBXjLdTmaYkzOIa-uIHnlWCCEm2MCCiMPg&sensor=true">
			</script>
			
			<script>
				function initialize(){
					var mapProp = {
						center: new google.maps.LatLng(-7.28755, 112.733),
						zoom: 5,
						mapTypeId: google.maps.MapTypeId.ROADMAP
					};
					var map = new google.maps.Map(document.getElementById("googleMap"), mapProp);
					allMaps.push(map);
					
					<?php
						if($all_titik_penjualan != null){
							foreach($all_titik_penjualan as $titik){
								echo "var marker".$titik['ID_TITIK_PENJUALAN']." = new google.maps.Marker();";
								echo "marker".$titik['ID_TITIK_PENJUALAN'].".setPosition(new google.maps.LatLng(".$titik['LAT'].", ".$titik['LON']."));";
								echo "marker".$titik['ID_TITIK_PENJUALAN'].".setMap(map);";
								
								echo "var content".$titik['ID_TITIK_PENJUALAN']." = 'Nama: ".$titik['NAMA']." <br>Alamat: ".$titik['ALAMAT']." <br>Rata Penjualan: ".$titik['PENJUALAN_NORMAL']."';";
								echo "var infoWindow".$titik['ID_TITIK_PENJUALAN']." = new google.maps.InfoWindow({content: content".$titik['ID_TITIK_PENJUALAN']."});";
								
								echo "onSpotClicked(marker".$titik['ID_TITIK_PENJUALAN'].", content".$titik['ID_TITIK_PENJUALAN'].", infoWindow".$titik['ID_TITIK_PENJUALAN'].", map);";
								
								echo "allMarkers[".$titik['ID_TITIK_PENJUALAN']."] = marker".$titik['ID_TITIK_PENJUALAN'].";";
							}
						}
					
					?>
					
				}
				
				function onSpotClicked(marker, content, infowindow, map){
					google.maps.event.addListener(marker, "mouseover", function () {
						infowindow.setContent(content);
						infowindow.open(map,this);
					});
					
					google.maps.event.addListener(marker, "mouseout", function () {
						infowindow.close();
					});
				}
				
				var markers = [];
				var allMaps = [];
				var allMarkers = [];
				google.maps.event.addDomListener(window, 'load', initialize);
				
			</script>
			<div class="row-fluid sortable ui-sortable">
	<div id="chart-permintaan" class="box span12">
		<div class="box-header well" data-original-title>
			<h2 id="action-title">Daftar Titik Pasok</h2>
			<div class="box-icon">
				<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
			</div>
		</div>
		<div class="box-content">
			<table class="table span5">
				<tr>
					<td>
						<label>Pilih Titik Pasok</label>
					</td>
					<td>
						<div class="controls">
							<select id="id-provinsi" data-rel="chosen" name='provinsi' onchange="drawGmaps(document.getElementById('id-provinsi').value);">
								<option value="0" selected>Semua Titik Pasok</option>
								<option value="1">Peternakan</option>
								<option value="2">RPH</option>
								<option value="3">Titik Penjualan</option>
								<option value="4">Agen</option>
							<?php
								/*foreach($provinsi as $key=>$data){
									echo "
										<option value='".$key."'>".$data."</option>
									";
								}*/
							?>
							</select>
						</div>
					</td>
				</tr>
			</table>
			<div id="ch-TP" style="height:400px"class=" box row-fluid sortable ui-sortable">
			</div>
		</div>
	</div>
</div>
			
			
			
			<div class="row-fluid sortable">
				<div class="box span6">
					<div class="box-header well" data-original-title>
						<h2>Sapi</h2>
						<div class="box-icon">
						</div>
						
					</div>
					<div class="box-content">
						<div id="piechart" style="width: 100%; height: 400px;"></div>
						   
					</div>
				</div><!--/span-->
				
				<div class="box span6">
					<div class="box-header well" data-original-title>
						<h2>Daging Sapi</h2>
						<div class="box-icon">
							
						</div>
					</div>
					<div class="box-content">
						   <div id="piechart2" style="width: 100%; height: 400px;"></div>
					</div>
				</div><!--/span-->
			</div><!--/row-->
			
			<div class="row-fluid sortable">		
				<div class="box span12">
					<div class="box-header well" data-original-title>
						<h2>Permintaan</h2>
						<div class="box-icon">
						</div>
					</div>
					<div class="box-content">
						<div id="chart_div" style="width: 100%; height: 1200px;"></div>
					</div>
				</div><!--/span-->
			
			